<template>
  <div :style="{height: tableHeight+'px'}" class="timeline-box">
    <div v-if="tableData.length">
      <el-table
          :data="tableData"
          size="mini"
          style="width: 100%">
        <el-table-column
            prop="create_time"
            label="日期"
            width="180">
        </el-table-column>
        <el-table-column
            prop="name"
            label="类型"
            width="180">
          <template slot-scope="scope">
            {{scope.row.type==0?'奖':'惩'}}
          </template>
        </el-table-column>
        <el-table-column
            prop="content"
            label="内容">
        </el-table-column>
        <el-table-column
            prop="address"
            label="操作"
            width="80">
          <template slot-scope="scope">
            <el-button size="mini" @click="detelDetailFn(scope.row.id)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-col :span="24" class="toolbar">
        <el-pagination
            background
            :page-size="page.pagesize"
            :current-page="page.pageindex"
            layout="total, prev, pager, next"
            :total="page.total"
            @current-change="handleSizeChange"></el-pagination>
      </el-col>
    </div>
    <div class="line-list" v-else>暂无记录</div>
  </div>
</template>

<script>
import {pagination} from '@/utils/util.js'
export default {
  props: ['resumeDetail', 'tableHeight','archives_id'],
  name: "Timeline",
  data() {
    return {
      color: '#069f71',
      page: {
        pageindex: pagination.pageIndex,
        pagesize: pagination.pageSize,
        total: pagination.total
      },
      tableData: [],
    }
  },
  created() {
    this.InitFn()
  },
  methods: {
    // 初始化
    async InitFn() {
      let data = await this.$fetch(this.api.archives.reward.index, {archives_id: this.archives_id,p:this.page.index});
      console.log(data)
      this.tableData = data.list.data;
      this.page.total = data.list.total;
    },
    BatchOperation(){
      this.InitFn()
    },
    // 关闭弹窗
    closePOpup() {
      this.$emit('update:visible', false)
    },
    getJson(option) {
      return JSON.parse(JSON.stringify(option))
    },
    handleSizeChange(val) {
      this.page.pageindex = val
      this.InitFn()
    },
    checkDetail(option) {
      console.log('查看简历审核详情');
      // this. @click="showPreview(2)"
      this.$emit('getDetailLine', option)
    },
    detelDetailFn(id) {
      this.$confirm('确认永久删除该课表, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.detelRespon(id)
      }).catch(() => {
      })
    },
    detelRespon(id) {
      this.$post(this.api.archives.reward.delete, {
        id: id,
      }).then((response) => {
        this.InitFn()
      }).catch((err) => {
        console.log(err)
      })
    },
  },
}
</script>

<style scoped>
.timeline-content {
  margin-top: 10px;
}

.timeline-content-check {
  color: #1b8de5;
  text-decoration: underline;
  cursor: pointer;
}

.timeline-box {
  overflow-y: auto;
}

.line-list {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #777;
  padding: 50px;
}
</style>
